<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>04.control_flow | KnockOut</title>
  <script src="../assets/knockout-3.5.1.js"></script>
</head>
<body>

  <!-- ko let: {
    inventory: {suppliers: suppliers, bins: bins}, 
    calculatedDisplay: someCalculation
  } -->
  <div data-bind="foreach: {data: inventory.suppliers, as: 'supplier'}">
    <div data-bind="foreach: {data: inventory.bins, as: 'bin'}">
      <span data-bind="text: calculatedDisplay(supplier, bin)">
    </div>
  </div>
  <!-- /ko -->

  <script type="text/javascript">
    var vm = {
      suppliers: [1, 2, 3],
      bins: ['a', 'b', 'c'],
      someCalculation: function (supplier, bin) {
        /* return some calculated value based on parameters */
        return supplier+bin;
      }
    }
    
    ko.applyBindings(vm);
  </script>
    
</body>
</html>